<?php

class AuthController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function loginAction()
    {
        $loginForm = new Form_Login();
 
        if ($this->getRequest()->isPost() && $loginForm->isValid($this->getRequest()->getPost())) {

            if (Model_Auth::authenticate($loginForm->getValue('email'), $loginForm->getValue('password'))) {
                $this->_helper->messenger->success('msg.auth_success');
                $this->_redirect('/');
                return;
            }

            $this->_helper->messenger->error('msg.auth_fail');
        }
        $this->view->loginForm = $loginForm;
    }

    public function logoutAction()
    {
		Zend_Auth::getInstance()->clearIdentity();
		$this->_redirect('/');
    }


}